<script setup>
import { ref } from 'vue'
import demoApi from '@/api/DemoApi'
// import useScrollEvent from '@/core/hooks/useTableBarEvent'

// const {scrollX, scrollY, clientW, clientH} = useScrollEvent()
const show = ref(false)


// 测试API调用

// 提交数组
const clickPostArrayEvt = () => {
  let frmData = { ids: ['22', '33', 'DDD'] }
  demoApi.postAarry(frmData).then(res => {
    alert(JSON.stringify(res))
  })
}
// 提交列表接收
const clickPostListEvt = () => {
  let frmData = { ids: ['List', '22', '33', 'DDD'] }
  demoApi.postList(frmData).then(res => {
    alert(JSON.stringify(res))
  })
}
// 提交列表接收
const clickPostBeanListEvt = () => {
  let frmData = [
    { value: '22', label: 'BB' },
    { value: '23', label: 'BC' }
  ]
  demoApi.postBeanList(frmData).then(res => {
    alert(JSON.stringify(res))
  })
}
// 提交列表接收
const clickPostBeanOneEvt = () => {
  let frmData = {
    id: 98,
    name: '什么东西',
    code: 'GD-GEGGGE',
    idx: 678,
    perms: ['22', '33', 'DDD'],
    pertion: { id: 10001, name: '小明和小强', age: 957 }
  }
  demoApi.postBeanOne(frmData).then(res => {
    alert(JSON.stringify(res))
  })
}
// 提交列表接收
const clickGetBeanOneEvt = () => {
  let frmData = {
    id: 1098,
    name: '什么东西',
    code: 'GD-GEGGGE',
    idx: 678,
    perms: ['22', '33', 'DDD'],
    pertion: { id: 10001, name: '黄小明和李小强', age: 579 }
  }
  demoApi.getBeanOne(frmData).then(res => {
    alert(JSON.stringify(res))
  })
}

const clickRequestEvt = () => {
  let frmData = {
    id: 1098,
    userName: '什么东西',
    pager: { size: 20001, current: 979, total: 666 }
  }
  demoApi.requestParams(frmData).then(res => {
    alert(JSON.stringify(res))
  })
}
// 提交列表接收
const clickPostBeanMoreEvt = () => {
  let frmData = {
    id: 98,
    name: '什么东西',
    code: 'GD-GEGGGE',
    idx: 678,
    perms: ['22', '33', 'DDD'],
    pertion: { id: 10001, name: '小明和小强', age: 957 },
    hasPerms: [
      { id: 10003, name: '小明AAAA', age: 957 },
      { id: 10005, name: '小强BBBB', age: 957 }
    ]
  }
  demoApi.postBeanMore(frmData).then(res => {
    alert(JSON.stringify(res))
  })
}

// 提交列表接收
const clickPostRulesEvt = () => {
  let frmData = {
    listName: '面食',
    age: ['21', '22', '23', '24'],
    person: {
      className: '百花丛中过g',
      operate: '人在',
      value: ['21', '22', '23', '24'],
      column: 'age'
    },
    rules: [
      { operate: '大于', value: ['21', '22', '23', '24'], column: 'age' },
      { operate: '特于', value: ['51', '52', '53'], column: 'testing' }
    ]
  }
  demoApi.postRules(frmData).then(res => {
    alert(JSON.stringify(res))
  })
}
// 提交列表接收
const clickPostBeanArryEvt = () => {
  // let frmData = {
  //   arry: [
  //     { value: "22", label: "BB" },
  //     { value: "23", label: "BC" }
  //   ]
  // };
  let frmData = [
    { value: '22', label: 'BB' },
    { value: '23', label: 'BC' }
  ]
  demoApi.postBeanArry(frmData).then(res => {
    alert(JSON.stringify(res))
  })
}
</script>
<template>
  <a-card title="Default size card" style="width: 800px">
    <template #extra><a href="#">more</a></template>
    {{ show }}
    ==<d-icon-font type="icon-ercikaifa" />
    <d-icon-font type="icon-neirongguanli" />
    <hr>
    <br>I18n =====> {{ $t('header.home') }}<br>
    <br>
    <a-button type="primary" @click="clickPostArrayEvt">
      clickPostArrayEvt 提交数组-OK
    </a-button>
    <a-button type="primary" @click="clickPostListEvt">
      clickPostListEvt 提交列表接收-OK
    </a-button>
    <a-button type="primary" @click="clickPostBeanListEvt">
      clickPostBeanListEvt 提交对象列表 -Ok
    </a-button>
    <a-button type="primary" @click="clickPostBeanOneEvt">
      clickPostBeanOneEvt 提交数组 -Ok
    </a-button>
    <a-button type="primary" @click="clickGetBeanOneEvt">
      clickGetBeanOneEvt 提交数组 -Ok
    </a-button>
    <a-button type="primary" @click="clickPostBeanMoreEvt">
      clickPostBeanMoreEvt 提交数组 -OK
    </a-button>

    <a-button type="primary" @click="clickPostRulesEvt">
      clickPostRulesEvt 提交数组 - OK
    </a-button>
    <a-button type="primary" @click="clickPostBeanArryEvt">
      clickPostBeanArryEvt 提交数组 - test
    </a-button>

    <a-button type="primary" @click="clickRequestEvt">
      clickRequestEvt 提交数组 -Ok @@@
    </a-button>
  </a-card>
</template>
<style lang="less" scoped>
.redtext {
  font-size: 26px;
  color: @link-color;
}
</style>